<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="jakarta.tags.core" %>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>写病历单 - 医疗预约系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Microsoft YaHei', sans-serif;
        }
        
        body {
            background-color: #f5f5f5;
            min-height: 100vh;
        }
        
        .header {
            background-color: #4a90e2;
            color: white;
            padding: 15px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .header h1 {
            font-size: 24px;
        }
        
        .header .user-info {
            display: flex;
            align-items: center;
        }
        
        .header .user-info span {
            margin-right: 15px;
        }
        
        .header .logout-btn {
            color: white;
            text-decoration: none;
            padding: 5px 10px;
            background-color: rgba(255,255,255,0.2);
            border-radius: 4px;
            transition: background-color 0.3s;
        }
        
        .header .logout-btn:hover {
            background-color: rgba(255,255,255,0.3);
        }
        
        .container {
            display: flex;
            min-height: calc(100vh - 60px);
        }
        
        .sidebar {
            width: 200px;
            background-color: #333;
            color: white;
        }
        
        .sidebar ul {
            list-style: none;
        }
        
        .sidebar li {
            padding: 15px 20px;
        }
        
        .sidebar a {
            color: white;
            text-decoration: none;
            display: block;
            transition: background-color 0.3s;
        }
        
        .sidebar li:hover {
            background-color: #4a90e2;
        }
        
        .sidebar li.active {
            background-color: #4a90e2;
        }
        
        .content {
            flex: 1;
            padding: 20px;
        }
        
        .page-title {
            font-size: 20px;
            margin-bottom: 20px;
            color: #333;
            display: flex;
            align-items: center;
        }
        
        .page-title .back-link {
            margin-left: auto;
            color: #4a90e2;
            text-decoration: none;
        }
        
        .page-title .back-link:hover {
            text-decoration: underline;
        }
        
        .form-card {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            padding: 20px;
        }
        
        .patient-basic-info {
            background-color: #f8f9fa;
            padding: 15px;
            border-radius: 4px;
            margin-bottom: 20px;
        }
        
        .patient-basic-info h4 {
            margin-bottom: 10px;
            color: #333;
        }
        
        .patient-basic-info p {
            margin-bottom: 5px;
            color: #666;
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            color: #555;
        }
        
        .form-group textarea {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 16px;
            resize: vertical;
            min-height: 120px;
            font-family: inherit;
        }
        
        .form-group textarea:focus {
            border-color: #4a90e2;
            outline: none;
        }
        
        .form-actions {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin-top: 30px;
        }
        
        .btn {
            padding: 10px 30px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s;
            text-decoration: none;
            display: inline-block;
            text-align: center;
        }
        
        .btn-primary {
            background-color: #4a90e2;
            color: white;
        }
        
        .btn-primary:hover {
            background-color: #357abD;
        }
        
        .btn-secondary {
            background-color: #6c757d;
            color: white;
        }
        
        .btn-secondary:hover {
            background-color: #5a6268;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>写病历单</h1>
        <div class="user-info">
            <span>欢迎您，${loginDoctor.doctorName}</span>
            <a href="/doctorLogout" class="logout-btn">退出登录</a>
        </div>
    </div>
    
    <div class="container">
        <div class="sidebar">
            <ul>
                <li><a href="/doctor/workspace">工作台</a></li>
                <li><a href="/doctor/appointments">我的排班</a></li>
                <li class="active"><a href="/doctor/patients">病人管理</a></li>
            </ul>
        </div>
        
        <div class="content">
            <h2 class="page-title">
                填写病历单
                <a href="/doctor/patients" class="back-link">返回列表</a>
            </h2>
            
            <div class="form-card">
                <!-- 病人基本信息 -->
                <div class="patient-basic-info">
                    <h4>病人信息</h4>
                    <p><strong>姓名：</strong>${visit.userName}</p>
                    <p><strong>性别：</strong>${visit.gender} | <strong>年龄：</strong>${visit.age}</p>
                    <p><strong>预约科室：</strong>${visit.departmentName}</p>
                    <p><strong>预约时间：</strong>${visit.appointmentTime}</p>
                    <p><strong>症状描述：</strong>${visit.symptom}</p>
                </div>
                
                <!-- 病历表单 -->
                <form id="medicalRecordForm" method="post" action="/doctor/medicalRecord/submit">
                    <input type="hidden" name="visitId" value="${visit.visitId}">
                    
                    <div class="form-group">
                        <label for="diagnosis">诊断结果</label>
                        <textarea id="diagnosis" name="diagnosis" required placeholder="请输入诊断结果"></textarea>
                    </div>
                    
                    <div class="form-group">
                        <label for="treatment">治疗方案</label>
                        <textarea id="treatment" name="treatment" required placeholder="请输入治疗方案"></textarea>
                    </div>
                    
                    <div class="form-group">
                        <label for="advice">医嘱</label>
                        <textarea id="advice" name="advice" required placeholder="请输入医嘱建议"></textarea>
                    </div>
                    
                    <div class="form-actions">
                        <button type="submit" class="btn btn-primary">提交病历</button>
                        <a href="/doctor/patients" class="btn btn-secondary">取消</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>